package com.huikeportal.service.impl;

import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huikeportal.dao.AspnetMembershipMapper;
import com.huikeportal.dao.CustomInfoMapper;
import com.huikeportal.model.AspnetMembership;
import com.huikeportal.model.MessageCommon;
import com.huikeportal.model.UserInfo;
import com.huikeportal.model.UserManagerInfo;
import com.huikeportal.service.CustomInfoService;

@Service("customInfoService")
public class CustomInfoServiceImpl implements CustomInfoService {

	@Autowired
	private CustomInfoMapper customInfoMapper;

	@Autowired
	private AspnetMembershipMapper aspnetMembershipMapper;

	/**
	 * 初始化获取用户信息
	 */
	public UserManagerInfo getCustomeInfo(UserInfo userInfo) throws Exception {
		return customInfoMapper.getCustomByName(userInfo);
	}

	/**
	 * 用户编辑信息提交
	 */
	public MessageCommon customSub(UserManagerInfo userManagerInfo)
			throws Exception {
		MessageCommon messageCommon = new MessageCommon();
		AspnetMembership aspnetMembership = new AspnetMembership();
		aspnetMembership.setUserid(userManagerInfo.getUserId());
		aspnetMembership.setEmail(userManagerInfo.getEmail());
		aspnetMembership.setLoweredemail(userManagerInfo.getEmail());
		aspnetMembership.setPhoneno(userManagerInfo.getTel());
		aspnetMembership.setMobilepin(userManagerInfo.getPhone());
		aspnetMembership.setRealname(userManagerInfo.getRealName());
		aspnetMembership.setModifytime(new Date());
		aspnetMembershipMapper.updateByPrimaryKeySelective(aspnetMembership);
		messageCommon.setFlag(true);
		messageCommon.setMessage("信息修改成功！");
		return messageCommon;
	}

}
